#pragma once
#include <d3d9.h>
#include <d3dx9.h>
#include <sstream>

using namespace std;

class PD3DCamera
{
private:
	D3DXVECTOR3 mPosition;
	D3DXVECTOR3 mLookAt;
	D3DXVECTOR3 mRight;
	D3DXVECTOR3 mUp;

	FLOAT mRotAroundUp;
	FLOAT mRotAroundRight;
	FLOAT mRotAroundLookAt;

	D3DXMATRIX mViewTransform;
	
	LPDIRECT3DDEVICE9 mDevice;
	BOOL mUpdateRequired;
	
	VOID UpdateCameraMatrices();
public:
	PD3DCamera(LPDIRECT3DDEVICE9 device);
	VOID LookAtPos(D3DXVECTOR3 *position, D3DXVECTOR3 *lookAt, D3DXVECTOR3 *up);
	VOID SetPosition(FLOAT x, FLOAT y, FLOAT z);
	VOID Update();
	D3DXVECTOR3* GetPosition();
	D3DXVECTOR3* GetLookAt();
	D3DXVECTOR3* GetRight();
	D3DXVECTOR3* GetUp();
	D3DXMATRIX* GetViewMatrix();

	VOID RotateDown(FLOAT angle);
	VOID RotateRight(FLOAT angle);
	VOID Roll(FLOAT angle);
	VOID MoveFoward(FLOAT dist);
	VOID MoveRight(FLOAT dist);
	VOID MoveUp(FLOAT dist);
	VOID MoveInDirection(FLOAT dist, D3DXVECTOR3* dir);
};
